/*
	Branch Process Unit
*/
module bpu
(
	input 	wire	[31:0]		operand1,
	input 	wire	[31:0] 		operand2,
	input  	wire	[02:0]  	func,
	input	wire				branchOp, 
	output  wire   				branchFlag
);
/*
	Because these operations are mutually exclusive, only half of them need to be calculated
*/
	wire	beqRes,bltRes,bltuRes;
	assign	beqRes		= 	operand1 == operand2;
	assign	bltRes		= 	$signed(operand1) <  $signed(operand2);
	assign	bltuRes		= 	operand1 <  operand2 ;

	
    assign  branchFlag	=	branchOp &&	( (!func[2] && !func[1]) && ((!func[0] && beqRes  )     || (func[0] && !beqRes )) ) | // BEQ  | BNE
                            			( ( func[2]  ^  func[1]) && ((!func[0] && bltRes  )     || (func[0] && !bltRes )) ) | // BLT  | BGE
                            			( ( func[2] &&  func[1]) && ((!func[0] && bltuRes )     || (func[0] && !bltuRes)) ) ; // BLTU | BGEU
endmodule
